﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.Common;
using Microsoft.Practices.EnterpriseLibrary.Data.Sql;
using Microsoft.Practices.EnterpriseLibrary.Common;
using System.Configuration;
using Insifo.BE.Seg;

namespace Insifo.DL.Seg
{
    public class Control
    {
        #region  Members

        /// <summary>
        /// Método obtiene los Origenes de Datos Activos
        /// </summary>
        /// <returns>Devuelve un DataSet</returns>
        public DataSet Listar(BEControl be)
        {
            DataSet ds = new DataSet();
            SqlDatabase sqlDB = new SqlDatabase(CadenaConexion.Obtener());
            DbCommand dbCmd = sqlDB.GetStoredProcCommand("Usp_CIDE_SEG_Control_Listar");
            dbCmd.CommandTimeout = CadenaConexion.CommandTimeout;
            try
            {
                sqlDB.AddInParameter(dbCmd, "@as_codigoaplicacion", DbType.String, be.CodigoAplicacion );
                sqlDB.AddInParameter(dbCmd, "@as_ventana", DbType.String, be.Ventana);
                sqlDB.AddInParameter(dbCmd, "@as_control", DbType.String, be.Control);
                ds = sqlDB.ExecuteDataSet(dbCmd);
            }
            catch (Exception)
            {
                throw;
            }
            finally
            {                
                //if (dbCmd.Connection.State == ConnectionState.Open)
                    //dbCmd.Connection.Close();
                dbCmd.Dispose();                
            }
            return ds;
        }


        #endregion  Members
    }
}
